#include "user.h"
#include<QtSql>
#include <string>
#include<iostream>
#include"dbutil.h"
#include<QMap>
using namespace std;
User ::User(QObject *parent):
    QObject(parent)
{}
QString User::findUserAuthority(QString loginname,QString password)
{
    Dbutil db;
    QSqlDatabase data;
    data=db.connect();
    QSqlQuery query;
    string username=loginname.toStdString();
    string passwd=password.toStdString();
    string sql = "select level from user where loginname='"+username+"'and passwd="+passwd;
    const char *k = sql.c_str();
     bool success = query.exec(k);
    if(success)  {

        while(query.next()) {
            authority=query.value(0).toInt();
            //qDebug()<<authority<<"hhhhhhhh"<<query.value(0);
            boolnum=1;
        }

    }
    else boolnum=0;

     db.dbclose(data);
    return query.value(0).toString();

}
int User::getauthority(void){
    //qDebug()<<authority<<"hhhhhhhh";
    return authority;
}
void User::setauthority(int autho){
    authority=autho;
}
int User::getboolnum(){
    return boolnum;
}
void User::setboolnum(int autho){
    boolnum=autho;
}
